package com.sansan.qiangji.realize.warehouse;

import com.sansan.qiangji.VO.warehouse.stackerTaskMove.StackerTaskMoveVO;
import com.sansan.qiangji.entity.warehouse.StackerTaskMove;
import com.sansan.qiangji.enums.ResultEnum;
import com.sansan.qiangji.exception.ServiceException;
import com.sansan.qiangji.service.impl.warehouse.StackerTaskMoveServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
@Slf4j
public class StackerTaskMoveReal {
    private StackerTaskMoveServiceImpl stackerTaskMoveService;

    @Resource
    public void setStackerTaskMoveService(StackerTaskMoveServiceImpl stackerTaskMoveService){
        this.stackerTaskMoveService = stackerTaskMoveService;
    }

    public StackerTaskMoveVO findByStackerTaskMoveCode(String stackerTaskMoveCode){
        StackerTaskMove stackerTaskMove = stackerTaskMoveService.findByStackerTaskMoveCode(stackerTaskMoveCode);
        if (stackerTaskMove == null){
            log.error("【移库任务】移库任务不存在");
            throw new ServiceException(ResultEnum.STACKER_TASK_MOVE_NOT_EXIST);
        }
        StackerTaskMoveVO stackerTaskMoveVO = new StackerTaskMoveVO();
        BeanUtils.copyProperties(stackerTaskMove, stackerTaskMoveVO);
        return stackerTaskMoveVO;
    }
}
